
/*#include <graphics.h>

int main()
{
    initgraph(640,640);
    setlinecolor(WHITE);
    setfillcolor(RED);
	int v_x,v_y;
	v_x=1;
	v_y=1;
	int i=0;
    BeginBatchDraw();
	int p_x=30,p_y=30;
    for(p_x=30; p_x<600; p_x++)
    {
	    
        circle(p_x,p_y,20);
        floodfill(p_x, p_y, WHITE);
        FlushBatchDraw();
        Sleep(10);
        cleardevice();
        p_x=p_x+v_x;
        p_y=v_y+p_y;
		if((p_x<=20)||(p_x>=620))
		v_x=-v_x;
	     if((p_y<=20)||(p_y>=640))
		v_y=-v_y;
    }

    EndBatchDraw();
    closegraph();
	return 0;
}*/
#include <graphics.h>
#define N 5
int main()
{
    initgraph(640,640);
    setlinecolor(WHITE);
    setfillcolor(YELLOW);
	int v_x[N]={1,2,1,1,1},v_y[N]={1,1,1,2,1};
	int p_x[N],p_y[N];
	int i;
    BeginBatchDraw();
	for(i=0;i<N;i++)
	{
    p_x[i]=rand()%400+40,p_y[i]=rand()%400+40;
	}
    while(1)
	{
	    for(i=0;i<N;i++)
		{
        circle(p_x[i],p_y[i],20);
        floodfill(p_x[i], p_y[i], WHITE);
        FlushBatchDraw();
		if((p_x[i]<=20)||(p_x[i]>=620))
		v_x[i]=-v_x[i];
	    if((p_y[i]<=20)||(p_y[i]>=640))
		v_y[i]=-v_y[i];
		p_x[i]=p_x[i]+v_x[i];
        p_y[i]=v_y[i]+p_y[i];
		Sleep(1);
		}
		cleardevice();
    }
    EndBatchDraw();
    closegraph();
	return 0;
}